<template>
  <a-dropdown>
    <a class="admin-container" @click.prevent>
      Admin
      <DownOutlined />
    </a>
    <template #overlay>
      <a-menu>
        <a-menu-item>
          <a href="javascript:;" @click="handleLogout">退出登录</a>
        </a-menu-item>
      </a-menu>
    </template>
  </a-dropdown>
</template>

<script lang="ts" setup>
import { useUserStore } from '@portal/stores/user';
import { useRouter } from 'vue-router';
import { DownOutlined } from '@ant-design/icons-vue';
import useCurrentInstance from '@/hooks/useCurrentInstance';

const userStore = useUserStore();
const router = useRouter();
const { globalProperties } = useCurrentInstance();
const handleLogout = async () => {
  await userStore.logout();
  // router.replace('/login');
  globalProperties.$message.success('退出成功！');
};
</script>

<style scoped lang="less">
.admin-container {
  display: block;
  white-space: nowrap;
}
</style>
